# https://leetcode.cn/problems/house-robber/description/

class Solution:
    def rob(self, nums: List[int]) -> int:
        n = len(nums)
        f = [0] * (n + 10)
        if n == 1:
            return nums[0]

        f[0] = nums[0]
        f[1] = max(nums[1], f[0])

        for i in range(2, n):
            f[i] = max(f[i - 1], nums[i] + f[i - 2])
        
        return f[n - 1]